<?php
	header('Content-Type:text/html; charset=utf-8');
	if(__FILE__ == ''){
		exit('System error');
	}

	date_default_timezone_set('Asia/Shanghai');
	define('Debug', true);
	if(Debug){
		error_reporting(E_ALL^E_NOTICE);
	}else{
		error_reporting(0);
	}

	define('WEB_PATH', str_replace('\\','/',dirname(__FILE__)));
	define('ROOT_PATH', dirname(WEB_PATH));
	set_include_path(ROOT_PATH.'/system'.PATH_SEPARATOR.ROOT_PATH.'/include'.PATH_SEPARATOR.get_include_path());
	require('Global.Func.php');
	require_once ('Zend/Loader/Autoloader.php');//加载ZEND文件

	Zend_Loader_AutoLoader::getInstance()->setFallbackAutoloader(TRUE);
	Zend_Loader_AutoLoader::getInstance()->pushAutoloader( NULL , 'Smarty_');

	$db_conf = new Zend_Config_Ini( ROOT_PATH.'/config.ini','homedatabase');
	$lang = new Zend_Config_Ini( ROOT_PATH.'/config.ini','lang');
	Zend_Registry::set('lang', $lang->toArray());

	$logger = new Zend_log(new Zend_Log_Writer_Stream(ROOT_PATH.'/data/logs/debug.log'));
	Zend_Registry::set('logger',$logger);

	$controller = Zend_Controller_Front::getInstance();
	$controller->setControllerDirectory(ROOT_PATH.'/app/Controllers/admin');
	$controller->setBaseUrl('http://'.$_SERVER['HTTP_HOST']);

	$db_params = array(
		'host' => $db_conf->database->host,
		'username' => $db_conf->database->user,
		'password' => $db_conf->database->password,
		'dbname' => $db_conf->database->dbname,
		'charset' => $db_conf->database->charset
	);

	/*初始化数据库对象*/
	$db = Zend_Db::factory ($db_conf->database->type, $db_params );
	Zend_Registry::set ( 'db', $db );

	/*配置语言包*/
	$lang = "";
	$view = new Zend_Controller_Action_Helper_ViewRenderer();
	$view->setView(new Templater('admin'));
	$view->setViewSuffix('tpl');//设置后缀
	Zend_Controller_Action_HelperBroker::addHelper ( $view );//载入视图
	
	$controller->dispatch ();
?>